package com.sphd.beautysalon.adapters;

import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sphd.beautysalon.R;
import com.sphd.beautysalon.info.SalesInfo;
import com.sphd.beautysalon.utils.Constant;
import com.wzh.frame.utils.BigDisMailUtils;
import com.wzh.frame.utils.StringUtils;
import com.wzh.frame.utils.TimeUtils;

import java.util.List;

/**
 * Created by Hu on 2016/12/9.
 */

public class StateAAdapter extends BaseQuickAdapter<SalesInfo> {
    int state;

    public StateAAdapter(int layoutResId, List<SalesInfo> data, int state) {
        super(layoutResId, data);
        this.state = state;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, SalesInfo salesInfo) {
        baseViewHolder
                .setText(R.id.tv_isosale, salesInfo.getOrder_isosale() == 1 ? "外卖" : "店内")
                .setText(R.id.receive_btn, state == 0 ? "接收" : state == 1 ? (salesInfo.getOrder_isosale() == 1 ? "派送" : "结账") : "结账")
                .setText(R.id.time_textview, "下单时间:" + TimeUtils.formatString(TimeUtils.DEFAULT_DATE_FORMAT, salesInfo.getOrder_regtime()))
                .addOnClickListener(R.id.receive_btn)
                .addOnClickListener(R.id.cancel_btn)
                .setText(R.id.orders_remark,state==6? (StringUtils.isEmpty(salesInfo.getOrder_remark())?"取消原因：暂无填写":"取消原因:"+salesInfo.getOrder_remark()):"")
                .setText(R.id.money_textview, "充值卡支付" + BigDisMailUtils.turnTrim(salesInfo.getOrder_cardpay(), Constant.DECIMAL_POINT)
                        + "\t现金支付" + BigDisMailUtils.turnTrim(salesInfo.getOrder_lastprice(),Constant.DECIMAL_POINT));

        Button cancel = baseViewHolder.getView(R.id.cancel_btn);
        LinearLayout layoutBtn = baseViewHolder.getView(R.id.bottom_layout_btn);
        RelativeLayout layoutAll = baseViewHolder.getView(R.id.bottom_layout);
        if (state==1){
            cancel.setVisibility(View.GONE);
        }else if (state==2){
            cancel.setVisibility(View.GONE);
        }else if (state==3){
            layoutAll.setVisibility(View.GONE);
        }else if (state==6){
            layoutBtn.setVisibility(View.GONE);
        }

    }
}
